package com.hliushi.domain;

import com.hliushi.strategy.RequestStrategy;

import java.util.List;

/**
 * 电梯系统
 *
 * @author: hliushi
 * @date: 2023/2/18 22:08
 **/
public class ElevatorSystem {

    private List<Elevator> elevators;

    private RequestStrategy strategy;

    public ElevatorSystem(List<Elevator> elevators) {
        this.elevators = elevators;
    }


    public void setStrategy(RequestStrategy strategy) {
        this.strategy = strategy;
    }

    /**
     * elevatorSystem takes an external request, and decide to push this request to an appropriate elevator
     *
     * @param request
     */
    public void handleExternalRequest(ExternalRequest request) {
        strategy.doHandleExternalRequest(request, this.elevators);
    }

    // /**
    //  * An elevator takes an internal request, determine if it's valid, inserts in its stop list
    //  *
    //  * @param request
    //  */
    // public void handleInternalRequest(InternalRequest request) {
    //     strategy.doHandleInternalRequest(request);
    // }

    /**
     * 如何知道一个函数，是否完成任务?
     * 地下一层电梯关闭，这时有人在地下一层按下向上的按钮, 会发生什么? 抛出异常 ?
     */

    public boolean valid() {
        return false;
    }


}
